AI tools in programming
Scientific workflows: Tools and Tips 🛠️
2024-01-18
What is this lecture series?
📅 Every 3rd Thursday 🕓 4-5 p.m. 📍 Webex
- One topic from the world of scientific workflows
- Material provided online
- If you don’t want to miss a lecture
Motivation
- AI tools assist programmers with
- Coding
- Debugging
- Learning
- …
- Higher productivity and efficiency
- More motivation
Today
Focus on integrated AI tools
- How to use GitHub Copilot to
- Speed up your coding
- Improve your code
- Learn
Concerns when using AI tools
Main goal: Motivate you to try out tools and find out what fits your workflow
Find other tools on the website
Now You
❓ What is your main programming language
❓ Which IDE (programming environment) do you use
❓ Which AI tools for programming did you already try
- Cloud-based AI tool by Github and OpenAI
- Model based on GPT-4 and OpenAI’s Codex
- Specifically trained on source code
- Basic idea: Plugin for your IDE to integrate Copilot
- Works best for well-represented languages (Python, JS, …)
How to get GitHub Copilot
It’s really easy, but you need:
- GitHub Account
- Active GH Copilot subscription (10$ per month)
- Get it for free as an academic with an educational account
- IDE that supports Copilot
- Full support: Visual Studio (Code), Vim, Neovim, JetBrains IDEs (e.g. PyCharm)
- Limited support: RStudio, ?
See website for step-by-step guide and more information.
Using GitHub Copilot
Demo of the main features and use cases
Inline code suggestions
- Copilot tries to predict what you want to do next
- Suggestions are based on the context
- Previous code
- Comments
- Variable and function names
- …
Get better suggestions
- Provide context
- Open other files
- Add top level comments explaining the purpose of the script
- Name variables and functions properly
- Copy-paste sample code and delete it later
- Be consistent
- “Garbage in, garbage out”
- Have a nice and consistent coding style
Nice side effect of using Copilot: More good-practice coding
Chat
- Ask and give commands regarding:
- Highlighted lines of code
- The whole script or project
- Preset commands starting with
/
/fix: fix problems in your code
/explain: explain this code
/test: write unit tests
/new: create new projects or scripts with code
- No inline code suggestions
- Great functionality to
- Explain code
- Suggestsions improve and enhance code
- Generate tests
- Not in RStudio, but in VS code and many other IDEs
- Free for personal use (for now)
Concerns to consider
- Privacy
- Chose whether your prompts and suggestions will be used by Github
Github -> Seetings -> Copilot -> Policies
- Plagiarism
- Block suggestions matching public code (
Github -> Seetings -> Copilot -> Policies)
- Ethical concerns
- For-profit tool trained on open-source
- Environmental concerns
Usage guidelines
- No definite guidelines, but see examples on lecture website
- Responsibility
- You are responsible for your scientific output
- Stay critical, double-check
- Transparency
- Make clear for which tasks you used which AI
- Know relevant guidelines
- Don’t use AI in exams
Summary
- AI tools for programming can be extremely useful
- Try different tools and find the ones you like
- Think about concerns
- Learn about relevant guidelines
- Development is fast, so keep up
- Check out the lecture website if you want to get started
Thank you for your attention :)
Questions?